<template>
  <footer class="footer">
    <span class="todo-count"
      >共有<strong>{{ list.length }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: status === '全部' }"
          @click="changeStatus('全部')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: status === '未完成' }"
          @click="changeStatus('未完成')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: status === '已完成' }"
          @click="changeStatus('已完成')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button @click="$emit('clear')" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      // 记录点了谁
      status: '全部'
    }
  },
  methods: {
    changeStatus (status) {
      this.status = status
      // 通知给父
      this.$emit('change', status)
    }
  }
}
</script>
